package com.ifly.voice.recognizer;

import android.content.Context;

import com.ifly.voice.app.App;
import com.ifly.voice.app.Logs;
import com.lidroid.xutils.util.LogUtils;

public class VoiceAdapter
{

	public static final int EXIT = 4;
	public static final int BACK = 5;
	public static String[] voiceDic = { "出境旅游", "出境游", "国内旅游", "国内游", "周边旅游", "周边游", "自由行", "退出", "返回", "上一页" };

	public static int getIdentify(String hyp)
	{
		if (hyp == null)
		{
			return -1;
		}
		LogUtils.d("hyp="+hyp);
		String[] split = hyp.split(" ");
		String lastString = split[split.length - 1];
		Logs.d("lastString=" + lastString);
		if (voiceDic[0].equals(lastString) || voiceDic[1].equals(lastString))
		{
			return 0;
		}
		else if (voiceDic[2].equals(lastString) || voiceDic[3].equals(lastString))
		{
			return 1;
		}
		else if (voiceDic[4].equals(lastString) || voiceDic[5].equals(lastString))
		{
			return 2;
		}
		else if (voiceDic[6].equals(lastString))
		{
			return 3;
		}
		else if (voiceDic[7].equals(lastString))
		{
			return EXIT;
		}
		else if (voiceDic[8].equals(lastString)||voiceDic[9].equals(lastString))
		{
			return BACK;
		}
		return -1;
	}

	public static void doEXIT(Context context)
	{
		App.getInstance().kill();
		android.os.Process.killProcess(android.os.Process.myPid());  
	}

}
